package com.example.viewpagertest2;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.ArrayList;

/**
 * Created by Michael on 2015/1/13.
 * 这个FragmentPagerAdapter不会销毁页卡
 */
public class ViewPagerFragmentAdpter2 extends FragmentPagerAdapter {

    private ArrayList<Fragment> fragmentList;

    private ArrayList<String> tabList;

    public ViewPagerFragmentAdpter2(FragmentManager fm,ArrayList<Fragment> fragmentList,ArrayList<String> tabList){
        super(fm);

        this.fragmentList = fragmentList;

        this.tabList = tabList;
    }

    @Override
    public Fragment getItem(int i) {
        return fragmentList.get(i);
    }

    @Override
    public int getCount() {
        return fragmentList.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return tabList.get(position);
    }
}
